package org.zs.miracle.common.response;

import java.io.Serial;

/**
 * 错误响应对象
 */
public class ErrorResponse extends AbstractResponse {
  
  @Serial
  private static final long serialVersionUID = -8369388190571799068L;
  
  public ErrorResponse() {
  }
  
  public ErrorResponse(String msg, String path, Boolean success) {
    super(ResponseCode.FAILED.getCode(), msg, path, success);
  }
  
  @Override
  public void setMessage(String message) {
    super.setMessage(message);
  }
  
  @Override
  public String getMessage() {
    return super.getMessage() != null ? super.getMessage() : "操作失败";
  }
  
  @Override
  public Boolean getSuccess() {
    return false;
  }
  
  /**
   * tostring json格式
   */
  @Override
  public String toString() {
    return "{" +
        "  'code' :" + code +
        ", 'message' : '" + message + '\'' +
        ", 'path' : '" + path + '\'' +
        ", 'success' : " + success +
        "}";
  }
}